<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>订单列表</title>
    <link rel="stylesheet" href="css/_all-skins.min.css"/>
    <link rel="stylesheet" href="css/AdminLTE.min.css"/>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/font-awesome.min.css"/>
    <link rel="stylesheet" href="css/daterangepicker.css"/>
    <link rel="stylesheet" href="css/select2.min.css"/>
    <link rel="stylesheet" href="css/layui.css"/>
    <link rel="stylesheet" href="css/layer.css"/>
    <link rel="stylesheet" type="text/css" href="css/hire_order.css"/>
</head>
<style>
    .label1 {
        color: red;
    }

    .order_form {
        position: absolute;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        left: 0;
        top: 0;
        z-index: 99999;
        text-align: center;
        display: none;
    }

    .order_form_text {
        display: inline-block;
        position: absolute;
        left: 40%;
        top: 200px;
        width: 350px;
        height: 240px;
        background: white;
        padding-top: 40px;
    }

    .order_form_text input {
        width: 250px;
        margin-top: 20px;
    }

    .order_save {
        width: 100px;
        margin-top: 30px;
        background: #3C8DBC;
        color: white;
    }

    .close_btn {
        position: absolute;
        right: 0px;
        top: 0px;
        font-size: 22px;
        color: white;
        display: inline-block;
        width: 50px;
        height: 30px;
        background: #3c8dbc;
    }

    .clear_date {
        height: 34px;
        width: 25px;
        margin-left: -25px;
        border: none;
        background: none;
        position: relative;
        z-index: 999;
    }
</style>
<body class="hold-transition skin-blue sidebar-mini fixed">
<div class="wrapper">

    <header class="main-header">
        <!-- Logo -->
        <div class="logo">
            <!-- mini logo for sidebar mini 50x50 pixels -->

            <!-- logo for regular state and mobile devices -->
            <span class="logo-lg"><b>SuitLove</b></span>
        </div>
        <!-- Header Navbar: style can be found in header.less -->
        <nav class="navbar navbar-static-top">
            <!-- Sidebar toggle button-->
            <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                <span class="sr-only">Toggle navigation</span>
            </a>

            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <li class="dropdown user user-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">

                            <img src="img/user2-160x160.jpg" class="user-image" alt="User Image">
                            <span class="hidden-xs  manger-name">Amy</span>

                            <span class="change_password" style="font-size: 12px;margin-left: 40px;">修改密码</span>
                            <span class="exit_login" style="font-size: 12px;">退出登录</span>
                        </a>

                    </li>
                </ul>
            </div>
        </nav>
    </header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">
            <!-- Sidebar user panel -->
            <div class="user-panel">
                <div class="pull-left image">
                    <img src="img/user2-160x160.jpg" class="img-circle">
                </div>
                <div class="pull-left info">
                    <p class="manger-name">Amy</p>
                    <a href="#"><i class="fa fa-circle text-success"></i> 在线</a>
                </div>
            </div>
            <!-- search form -->
            <form action="#" method="get" class="sidebar-form">
                <!--<div class="input-group">-->
                    <!--<input type="text" name="q" class="form-control" placeholder="Search...">-->
                    <!--<span class="input-group-btn">-->
                <!--<button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>-->
                <!--</button>-->
              <!--</span>-->
                <!--</div>-->
            </form>
            <!-- /.search form -->
            <!-- sidebar menu: : style can be found in sidebar.less -->
            <ul class="sidebar-menu" data-widget="tree">
                <li class="header">功能目录</li>

                <li class=" treeview">
                    <a href="#">
                        <i class="fa fa-dashboard"></i> <span>系统首页</span>
                        <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                    </a>
                    <ul class="treeview-menu">
                        <!--<li><a href="login_log.html"><i class="fa fa-circle-o"></i> 登录日志</a></li>-->
                        <li><a href="id_manager.html"><i class="fa fa-circle-o"></i> 账号管理</a></li>
                    </ul>
                </li>

                <li class=" treeview">
                    <a href="#">
                        <i class="fa fa-laptop"></i>
                        <span>商品管理</span>
                        <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="product_list.html"><i class="fa fa-circle-o"></i> 商品列表</a></li>
                        <li><a href="new_product.html"><i class="fa fa-circle-o"></i> 新增商品</a></li>
                        <li><a href="product_kind.html"><i class="fa fa-circle-o"></i> 商品分类</a></li>
                        <!--<li><a href="product_confirm.html"><i class="fa fa-circle-o"></i> 商品审核</a></li>-->
                        <!--<li><a href="product_income.html"><i class="fa fa-circle-o"></i> 商品回收</a></li>-->
                    </ul>
                </li>

                <li class="active treeview">
                    <a href="#">
                        <i class="fa fa-edit"></i> <span>订单管理</span>
                        <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                    </a>
                    <ul class="treeview-menu">
                        <li class="active"><a href="hire_order.html"><i class="fa fa-circle-o"></i> 订单列表</a></li>
                        <!--<li><a href="pay_order.html"><i class="fa fa-circle-o"></i> 支付订单</a></li>-->
                        <!--<li><a href="operate_log.html"><i class="fa fa-circle-o"></i> 订单日志</a></li>-->
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa fa-pie-chart"></i>
                        <span>会员管理</span>
                        <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="pay_order.html"><i class="fa fa-circle-o"></i> 会员记录</a></li>
                        <!--<li><a href="discounts.html"><i class="fa fa-circle-o"></i> 优惠卷中心</a></li>-->
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa fa-pie-chart"></i>
                        <span>团购加盟</span>
                        <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="group_buy.html"><i class="fa fa-circle-o"></i> 团购信息</a></li>
                        <li><a href="join_in.html"><i class="fa fa-circle-o"></i> 加盟信息</a></li>
                        <!--<li><a href="order_data.html"><i class="fa fa-circle-o"></i>订单数据</a></li>-->
                        <!--<li><a href="user_data.html"><i class="fa fa-circle-o"></i>用户数据</a></li>-->
                        <!--<li><a href="income_data.html"><i class="fa fa-circle-o"></i>收入数据</a></li>-->
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa fa-pie-chart"></i>
                        <span>活动管理</span>
                        <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="activity.html"><i class="fa fa-circle-o"></i> 活动管理</a></li>
                        <!--<li><a href="discounts.html"><i class="fa fa-circle-o"></i> 优惠卷中心</a></li>-->
                    </ul>
                </li>
            </ul>
        </section>
        <!-- /.sidebar -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">


        <!-- Main content -->


        <section class="content">

            <!-- Main row -->
            <div class="row">
                <!-- Left col -->
                <div class="col-lg-1"></div>
                <section class="col-lg-10 connectedSortable ">
                    <div style="padding: 0;">
                        <div class="search_box">
                            <span class="search_title">条件筛选</span>
                            <div style="display: inline-block;width:640px;">
                                <input type="text" class="form-control search_text num_text" placeholder="手机号码"/>
                                <input type="text" class="form-control name_text" placeholder="商品名"/>

                                <select id="order_status" class="select2 form-control">
                                    <option value="全部">全部</option>
                                    <option value="待发货">待发货</option>
                                    <!--<option value="待归还">待归还</option>-->
                                    <option value="待收货">待收货</option>

                                    <!--<option value="已归还">已归还</option>-->
                                    <option value="已完成">已完成</option>
                                    <option value="已取消">已取消</option>
                                </select>
                                <!--<br />-->
                                <!--<input type="text" placeholder="请输入时间范围" class="date_pick form-control " id="reservation" ><button class="clear_date">x</button>-->
                                <input class="search_btn1 search_order" type="button" style="margin-left: 20px"
                                       value="查询"/>
                            </div>
                            <div style="display: inline-block;width: 200px;">
                                <!--<input class="search_btn1 search_order" type="button" value="查询"/>-->
                                <!--<input class="search_btn1" type="button" value="导出订单"/>-->
                            </div>
                        </div>

                    </div>

                </section>

            </div>
            <div class="row">
                <div class="col-lg-1"></div>
                <div class="col-lg-10 table_content">
                    <!--<h5 class="search_title" style="margin-top: 10px;">商品列表</h5>-->
                    <table class="list_content">
                        <thead>
                        <tr>
                            <th>订单编号</th>
                            <th>收件人</th>
                            <th>用户手机号</th>
                            <th>订单商品</th>
                            <th>商品数量</th>
                            <th>订单时间</th>
                            <th style="width: 130px;">订单状态</th>
                            <th style="width: 180px;">操作</th>
                        </tr>
                        </thead>
                        <tbody class="table_data">

                        </tbody>
                    </table>
                </div>
                <div class="row col-lg-12" style="text-align: center;margin-top: 10px;">
                    <div class="col-lg-1"></div>
                    <div id="demo7" class="col-lg-10" style="padding: 0;"></div>
                </div>
            </div>

        </section>
        <!-- /.content -->
    </div>

    <!-- /.content-wrapper -->
    <footer class="main-footer">
        <div class="pull-right hidden-xs">
            <b>Version</b> 2.0.0
        </div>
        <strong>Copyright &copy; 2018-2019 <a href="http://www.han5j.com/">西安寒武纪信息科技有限公司</a>.</strong> All rights
        reserved.
    </footer>
</div>
<div class="order_form">
    <div class="order_form_text">
        <span class="close_btn"><i class="fa fa-times" aria-hidden="true"></i> </span>
        <label>物流：</label>
        <!--<input type="text" class="form-control send_text"/>-->
        <select class="form-control send_text" style="width: 249px">
            <option value="顺丰速运">顺丰速运</option>
            <option value="圆通快递">圆通快递</option>
            <option value="中通快递">中通快递</option>
            <option value="申通快递">申通快递</option>
            <option value="韵达快递">韵达快递</option>
            <option value="百世快递">百世快递</option>
            <option value="京东快递">京东快递</option>
            <option value="邮政EMS">邮政EMS</option>
            <option value="天天快递">天天快递</option>
            <option value="宅急送">宅急送</option>
        </select>
        <br/>
        <label>单号：</label><input type="text" onkeyup="value=value.replace(/[^\d]/g,'')"
                                 class="form-control send_num"/><br/>
        <input type="button" class="form-control order_save " value="提交">
    </div>
</div>

<script src="js/jquery.min.js"></script>


<script src="js/adminlte.min.js"></script>
<script type="text/javascript" src="js/moment.min.js"></script>
<script src="js/daterangepicker.js"></script>
<script type="text/javascript" src="js/select2.full.min.js"></script>
<script src="js/layui.all.js"></script>

<script src="js/bootstrap.min.js"></script>
<script src="js/jq.cookie.js"></script>
<script src="js/change_password.js"></script>
<script>
    $('.select2').select2();
    $('#reservation').daterangepicker({
        startDate: '2017-10-10',
        locale: {format: 'YYYY-MM-DD'}
    });
    $('#reservation').val('请选择时间');

    $('.search_order').click(function () {
        getData1(1);
    })

    var orderN = '';
    var orderM = '';

    getData1(1);

    function pageDivd(curr, page_num) {
        layui.use(['laypage', 'layer'], function () {
            var laypage = layui.laypage
                , layer = layui.layer;
            laypage.render({
                elem: 'demo7'
                , count: page_num
                , limit: 20
                , curr: curr
                , jump: function (obj, first) {
                    if (!first) {
                        getData1(obj.curr);

                    }
                }
            });
        })
    }

    function TableView(data) {
        $('.table_data').html('');

        for (var i = 0; i < data.length; i++) {
            var operateBox;
            var labelText;
            if (data[i][6] == '待发货') {
                labelText = `<label class="label1">${data[i][6]}</label>`;
                operateBox = `<div class="btn_done">
		      		    				<a class="order_send order_btn" index="1" href="#">订单发货</a>
		      		    				<a class="order_detail" href="#">订单详情</a>
		      		    			</div>`;

            } else if (data[i][6] == '待归还') {
                labelText = `<label class="label1">${data[i][6]}</label>`;
                operateBox = `<div class="btn_done">
		      		    				<a class="order_btn" index="2" href="#">确认归还</a>
		      		    				<a class="order_detail" href="#">订单详情</a>
		      		    			</div>`;

            } else if (data[i][6] == '已取消') {
                labelText = `<label class="label1">${data[i][6]}</label>`;
                operateBox = `<div class="btn_done">
		      		    				<a class="order_btn" index="3" href="#">关闭订单</a>
		      		    				<a class="order_detail" href="#">订单详情</a>
		      		    			</div>`;
            } else {
                labelText = `<label class="">${data[i][6]}</label>`;
                operateBox = `<div class="btn_done">
		      		    				<a class="order_detail" href="#">订单详情</a>
		      		    			</div>`;
            }


            var trText = `<tr num="${data[i][0]}">
		      		    		<td>${data[i][0]}</td>
		      		    		<td>${data[i][1]}</td>
		      		    		<td>${data[i][2]}</td>
		      		    		<td>
		      		    			${data[i][3]}
		      		    		</td>
		      		    		<td>
		      		    			${data[i][4]}
		      		    		</td>
		      		    		<td>
		      		    			${data[i][5]}
		      		    		</td>
		      		    		<td>
		      		    			${labelText}
		      		    		</td>
		      		    		<td>
		      		    			${operateBox}
		      		    		</td>
		      		    	</tr>
		      		    	`;

            $('.table_data').append(trText);

        }
        // console.log($.cookie('UserId'))
        look_detail();
    }

    function look_detail() {
        $('.order_detail').click(function () {
            var Index = $(this).parents('tr').attr('num');
            window.location.href = "http://www.puer.zone:9000/order_detail.html?num=" + Index;


        })

        var order_id;
        //订单发货
        $('.order_send').click(function () {
            $('.order_form').css('display', 'block');
            $('.close_btn').click(function () {
                $('.order_form').css('display', 'none');
            })
            order_id = $(this).parent().parent().parent().attr('num');
        })
        //提交
        $('.order_save').click(function () {
            // console.log(1)
            var num = $('.send_num').val();
            if (num == '') {
                layer.msg('请填写单号');

            } else if (isNaN(num)) {
                layer.msg('请填写数字');

            } else {
                $.ajax({
                    type: "get",
                    url: "http://www.puer.zone:30000/OrdersToBeDelivered",
                    async: true,
                    data: {
                        Id: order_id,
                        // Kind:orderN,
                        company: $('.send_text').val(),
                        no: num,
                        // UserId:$.cookie('UserId')
                    },
                    success: function (data) {
                        if (data == 'success') {
                            layer.msg('提交成功', {time: 500}, function () {
                                location.reload();
                            })
                            // $('.order_form').css('display','none');
                        } else {
                            layer.msg('提交失败')
                        }
                    }
                });
            }

        })

        //关闭订单
        $('.order_btn').click(function () {
            var index = $(this).attr('index');
            var orderNum = $(this).parents('tr').attr('num');

            orderN = $(this).attr('index');
            orderM = $(this).parents('tr').attr('num');
            if (index != 1) {
                $.ajax({
                    type: "get",
                    url: "http://www.puer.zone:30000/",
                    async: true,
                    data: {
                        Id: orderNum,
                        Kind: index,
                        Company: $('.send_text').val(),
                        No: $('.send_num').val(),
                        UserId: $.cookie('UserId')
                    },
                    success: function (data) {
                        if (data == 'success') {
                            layer.msg('提交成功')
                        } else {
                            layer.msg('提交失败')
                        }
                    }
                });
            }


        })

    }

    function getData1(curr) {
        // var data_rang = $('#reservation').val();//时间范围
        var status = $('#order_status').select2('val');
        // var start = data_rang.split(' -')[0];
        // var end = data_rang.split('- ')[1];
        // var timeOnoff = "False";
        // if(data_rang!=''&&data_rang!='请选择时间'){
        // 	timeOnoff = "True"
        // }
        $.ajax({
            type: "get",
            url: "http://www.puer.zone:30000/OrdersInfo",
            async: true,
            data: {
                page: curr,
                row: 20,
                product: $('.name_text').val(),
                phone: $('.num_text').val(),
                // end:end ,
                status: status,
                // start:start ,
                // Time:timeOnoff
            },
            success: function (data) {
                if (data[0].length == 0) {
                    layer.msg('暂无数据')
                }
                TableView(data[0]);
                pageDivd(curr, data[1]);
                $('.all_data').html(data[1])
            }
        });
    }

</script>
</body>
</html>
